﻿⍝ Futures and Isolate script for Dyalog'14 Workshop
⍝ Part 1 - Isolate is a Namespace
)load isolate
ns1←⎕NS ''     ⍝ create empty namespace
ns1.x←1 2 3
ns1.(x+1)
ns1.(+/x÷≢x)   ⍝ mean of x
is1←ø ''       ⍝ ø ←→ ¤ ←→ isolate.New
is1.x←4 5 6 7
is1.(+/x÷≢x)   
is1.avg←{(+/⍵)÷≢⍵}
is1.(avg←{(+/⍵)÷≢⍵})
is1.(avg x)
is1.(⎕FX ,⊂'avg←{(+/⍵)÷≢⍵}')
ns1.(avg←{(+/⍵)÷≢⍵})
is1←isolate.New ns1 ⍝ Clone ns1 as an isolate
is1.(avg x)
⎕FX 'r←mean x' 'r←(+⌿ ÷ ≢) x'
y←1 2 3 4
mean y
is2←isolate.New 'mean' 'y'
is2.(mean y)
is3←isolate.New (+2 ⎕NQ '.' 'GetEnvironment' 'DYALOG'),'ws\dfns.dws' ⍝ Simple char = ws name
is3.(fibonacci¨⍳20)
iss←ø¨ 3⍴ns1 ⍝ THREE clones of ns1
iss
]boxing on
iss.x
⎕←data←?3 4⍴100 ⍝ "big data" :-)
↓data
iss.x←↓data
iss.x
iss.(x+1)
iss.x+1
iss.(avg x)
]runtime "⎕←ns1.(⎕DL 3)" "⎕←is1.(⎕DL 3)"
⍝ So, what's the point??!!
twelve←is1.⎕DL 12
2+2
4×3
twelve
)erase is1 is2 is3 twenty
⍝ Exercise:
⍝  - Create an array of isolates with the same function
⍝  - and different data in them, and call the function.

